<?php

class AdminAplicationController extends Controller
{
	
	public $layout='//layouts/column2_user';
	
	public function actionIndex()
	{
		$this->render('index');
	}


	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		
		$return_name = array();
		$noAdmins = User::model()->findAllByAttributes(array('superuser'=>'0'));
		
		
		
		foreach ($noAdmins as $noAdmin)
			array_push($return_name,$noAdmin->username);
		
		return array(
				array('allow', // allow authenticated user to perform 'create' and 'update' actions
						'actions'=>array('create','update'),
						'users'=>array('admin'),
				),
				array('allow', // allow admin user to perform 'admin' and 'delete' actions
						'actions'=>array('admin','delete','index'),
						'users'=>$return_name,
				),
				array('deny',  // deny all users
						'users'=>array('*'),
				),
		);
	}
	
	

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
				'accessControl', // perform access control for CRUD operations
		);
	}
	
}